﻿using System;
using System.Windows.Data;
using System.IO;
using System.Windows.Media.Imaging;

namespace Skyper.Data {
	public class AvatarConverter : IValueConverter {

		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
			return Convert(value);
		}
		public static object Convert(object value) {
			if (value is Stream) {
				Stream s = (Stream)value;

				BitmapImage img = new BitmapImage();
				img.SetSource(s);

				return img;
			}
			return new BitmapImage(new Uri("/Images/General/Contact_48x48.png", UriKind.Relative));
		}
		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
			throw new NotImplementedException();
		}
	}
}
